﻿using System.Reflection;
using NExt.Handler.Base.Common.Cache;

namespace NExt.Handler.Base.Common.Manager
{
    public class AssemblyManager : ConcurrentCache<AssemblyManager, string, Assembly>
    {
        public static Assembly GetAssembly(string fileName)
        {
            Assembly assembly = GetOrAdd(fileName, () => Assembly.Load(fileName));
            return assembly;
        }

        public static string GetJsName(Assembly assembly)
        {
            string assemblyName = assembly.GetName().Name;
            string assemblyJsName = string.Format("{0}.Assembly", assemblyName);
            return assemblyJsName;
        }
    }
}
